from dajax.core import Dajax
from django.utils import simplejson
from dajaxice.core import dajaxice_functions
from django.views.decorators.csrf import csrf_exempt

from fixtures.models import *
from cue.models import *


@csrf_exempt
def myexample(request):
	totalCues = Property.objects.get(pk=2).name
#	test = Property(
#		name="color",
#		value="blue",
#		defaultOffValue="black")
#	test.save()
	return simplejson.dumps({'message':totalCues})
	
@csrf_exempt
def getCueTransitions(request, data):
	cue = Cue.objects.get(pk=data)
	id=data
	tJ = "["
	for i in range(cue.transitions.count()):
		tJ = tJ + cue.transitions.all()[i].json() + ","
	tJ = tJ[:-1]
	tJ = tJ + "]"
	return simplejson.dumps({'cueID':id, 'transitions':tJ})	
    
dajaxice_functions.register(myexample)
dajaxice_functions.register(getCueTransitions)